package com.bamboo.tool.listeners;

import com.bamboo.tool.config.BambooToolComponent;
import com.bamboo.tool.config.model.ProjectInfo;
import com.bamboo.tool.config.model.RestfulCloudConfig;
import com.bamboo.tool.store.StoreService;
import com.bamboo.tool.util.TaskUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManagerListener;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class MyProjectManagerListener implements ProjectManagerListener {

    @Override
    public void projectOpened(@NotNull Project project) {
        TaskUtil.run(project, "Restful Cloud 加载配置", initSetting(project));
    }

    private static Runnable initSetting(@NotNull Project project) {
        return () -> {

            StoreService storeService = BambooToolComponent.getStoreService();
            storeService.initTable();
            storeService.initData();
            storeService.deleteInvalidProject();
        };

    }

}
